let url = "http://120.27.144.38:80/"

function randomId(start) {

    var five="";
    var now = new Date();
    var y=now.getFullYear().toString();
    var M=zero(now.getMonth()+1);

    var d=zero(now.getDate())

    var hour=zero(now.getHours().toString());
    var m=zero(now.getMinutes().toString());

    var s=zero(now.getSeconds().toString());

    for (var i = 0; i < 5; i++) {
        five+=Math.round(Math.random()*9)
    }

    var str = y + M+d+hour+m+s+five;
    if(start){
        return start + str;
    }else{
        return str
    }
   


}
function zero(time){
if (time<10) {
    return time="0"+time;
}else{
    return time;
}
}
// 超过万用万单位
function changeNum(num){
   return  num>10000?(((num-num%1000)/10000+'W')):(num)
}
// 判断登陆
function isLogin(){
    if(localStorage.getItem("userName")&&localStorage.getItem("passWord")){
        return true;
    }else{
        return false;
    }
}
function totalPage(){
  
    const hashLocation= sessionStorage.getItem("hashLocation");//缓存中获取当前页面的路由名称
  
    const newLocation = hashLocation.split("#/")[1];
    this.$matomo.setCustomUrl(url+newLocation);//覆盖页面报告的url，可以自定义页面url，加上本页面路由
    // this.$matomo.trackEvent(shopCode,hashLocation);//事件
    this.$matomo.trackPageView(hashLocation);//页面名称,可以自定义页面名称
           
           
  
}
module.exports = {
    randomId,changeNum,isLogin,totalPage
}